<?php

class important extends connector {

	function important() {
		$this->softbase(true);
	}
	
	function oncommentlist() {
		$this->powercheck(253, 254);
		parent::start_template();
		$lng = (admin_LNG == 'big5') ? $this->CON['is_lancode'] : admin_LNG;
		$MinPageid = intval($this->fun->accept('MinPageid', 'R'));
		$page_id = intval($this->fun->accept('page_id', 'R'));  //当前页
		$countnum = intval($this->fun->accept('countnum', 'R'));
		$MaxPerPage = intval($this->fun->accept('MaxPerPage', 'R'));  //每页多少条
		if (empty($MaxPerPage)) {
			$MaxPerPage = $this->CON['max_list'];
		}
		$hid = $this->fun->accept('hid', 'R');
		$hname = $this->fun->accept('hname', 'R');
		$uid = $this->fun->accept('uid', 'R');
		$username  = $this->fun->accept('username', 'R');
		
		$db_where = " WHERE 1 ";
		if (!empty($hid)) {
			$db_where.=" AND hid=" . $hid;
		}
		if (!empty($hname)) {
			$db_where.=" AND hname like '%" . $hname ."%'";
		}
		if (!empty($uid)) {
			$db_where.=" AND uid=" . $$uid;
		}
		if (!empty($username)) {
			$db_where.=" AND username like '%" . $username ."%'";
		}
		
		$limitkey = $this->fun->accept('limitkey', 'R');
		$limitkey = empty($limitkey) ? 'cid' : $limitkey;

		$limitclass = $this->fun->accept('limitclass', 'R');
		$limitclass = empty($limitclass) ? 'DESC' : $limitclass;
		$db_table = db_prefix . 'hotel_comment';
		if (!empty($countnum)) {
			$countnum = $this->db_numrows($db_table, $db_where);
			exit($countnum);
		}
		$array = array();
		$sql = 'SELECT * FROM ' . $db_table . $db_where . ' ORDER BY ' . $limitkey . ' ' . $limitclass . ' LIMIT ' . $MinPageid . ',' . $MaxPerPage;
		$rs = $this->db->query($sql);
		while ($rsList = $this->db->fetch_assoc($rs)) {
			$showurl = $this->get_link("hotelshow",array('hid'=>$rsList['hid']),$lng);
			$rsList['showurl'] = $showurl;
			$rsList['datetime'] = date('Y-m-d H:i:s',$rsList['datetime']);
			$array[] = $rsList;
		}
		
		$this->fun->setcookie($this->fun->noncefile() . 'pgid', $page_id, 600);
		$this->ectemplates->assign('array', $array);
		$this->ectemplates->assign('sql', $sql);

		$outtemplatefile = 'comment/comment_list';
		$this->ectemplates->display($outtemplatefile);
	}
	
	function ondel() {
		$this->powercheck(253, 255);
		$db_table = db_prefix . 'hotel_comment';
		$selectinfoid = $this->fun->accept('commentid', 'P');
		if (empty($selectinfoid)) exit('false');
		$infoarray = explode(',', $selectinfoid);
		$count = count($infoarray) - 1;
		if ($count <= 0) exit('false');
		$selectinfoid = $selectinfoid . '0';
		$db_where = "cid in ($selectinfoid)";
		$this->db->query('DELETE FROM ' . $db_table . ' WHERE ' . $db_where);
		exit('true');
	}
	
}


?>